//
//  ComponentInfo.m
//  Dolphin
//
//  Created by Handymood on 11-5-22.
//  Copyright 2011 __Hanydmood__. All rights reserved.
//

#import "LayerInfo.h"

@implementation LayerInfo
@synthesize type;
@synthesize resPath;
@synthesize target_album_xml;
@synthesize x;
@synthesize y;
@synthesize width;
@synthesize height;
@synthesize fade;

@synthesize imgWidth;
@synthesize imgHeight;

@synthesize imgArr;

@synthesize imgSize;

@synthesize autoPlay;
@synthesize isLoop;
@synthesize showButton;

@synthesize ratioMode;
@synthesize useOriginalSize;

@synthesize target_page_id;

@synthesize scroll_width;
@synthesize scroll_height;

@synthesize style;
@synthesize msg;
@synthesize target_video_path;

@synthesize          startOffX;
@synthesize          startOffY;
@synthesize          startAlpha;   
@synthesize          delay;
@synthesize          duration;
@synthesize          transitionType;

@synthesize          ani;
@synthesize          anistartindex;
@synthesize          aniendindex;

@synthesize          aniprefix;
@synthesize          anisuffix;

@synthesize          aniduration;
@synthesize          anirepeat;
@synthesize          discrete;
@synthesize          value;
@synthesize          hit_img;
/*
 NSString *type;
 NSString *resPath; 
 
 CGFloat x;
 CGFloat y;
 CGFloat width;
 CGFloat height;
 
 //For Button Slide
 NSArray   *imgArr;
 CGFloat    imgWidth;
 CGFloat    imgHeight;
 
 //For Video Player
 BOOL       autoPlay;
 BOOL       isLoop;
 */
-(void) initDefaultSet
{
    x = 0;
    y = 0;
    width = 0;
    height = 0;
    
    //For Button Slide
    imgWidth = 0;
    imgHeight = 0;
    
    //For Video Player/Audio
    autoPlay = FALSE;
    isLoop = FALSE;
    
    //Audio
    showButton = FALSE;
    
    //For Image 
    ratioMode = 0;
    useOriginalSize = FALSE;  
    
    //For Click Event
    target_page_id = -1;
    
    //For Scroll
    scroll_width = 0;
    scroll_height = 0;
    
    //For Video Player
    style = 0;
    fade = 0;
    
    //For Start Animation
    startOffX = 0.0f;
    startOffY = 0.0f;
    startAlpha = 0.0f;   
    delay = 0.0f;
    duration = 0.0f;
    transitionType = 0;
    
    ani = 0;
    anistartindex = 1;
    aniendindex = 1;    
    aniprefix = @"";
    anisuffix = @"";
    anirepeat = 0;
    aniduration = 0;
    discrete = 2;        
    hit_img = @"";
}

-(void) copyWithNewInfoObject:(LayerInfo *) newInfoObj
{
    if (newInfoObj) 
    {
        if(type)
        {
            newInfoObj.type = [[NSString alloc] initWithString:type];
        }
        
        if(resPath)
        {
            newInfoObj.resPath = [[NSString alloc] initWithString:resPath];
        }
        
        if (target_album_xml) 
        {
            newInfoObj.target_album_xml = [[NSString alloc] initWithString:target_album_xml];
        }
        
        if (msg) 
        {
            newInfoObj.msg = [[NSString alloc] initWithString:msg];
        }
        
        if (value) 
        {
            newInfoObj.value = [[NSString alloc] initWithString:value];
        }
        
        if (target_video_path) 
        {
            newInfoObj.target_video_path = [[NSString alloc] initWithString:target_video_path];
        }
        
        if (aniprefix)
        {
            newInfoObj.aniprefix = [[NSString alloc] initWithString:aniprefix];

        }
        
        if(anisuffix)
        {
            newInfoObj.anisuffix = [[NSString alloc] initWithString:anisuffix];
        }
        
        if (hit_img) 
        {
            newInfoObj.hit_img = [[NSString alloc] initWithString:hit_img];
        }
        
        newInfoObj.x = x;
        newInfoObj.y = y;
        newInfoObj.width = width;
        newInfoObj.height = height;
        
        //For Button Slide
        if(imgArr)
        {
            newInfoObj.imgArr = [[NSMutableArray alloc] init];
            for (int i=0; i<[imgArr count]; i++) 
            {
                [newInfoObj.imgArr addObject:[[NSString alloc] initWithString:[imgArr objectAtIndex:i]]];
            }
        }
        
        newInfoObj.imgWidth = imgWidth;
        newInfoObj.imgHeight = imgHeight;
        
        //For Video Player/Audio
        newInfoObj.autoPlay = autoPlay;
        newInfoObj.isLoop = isLoop;
        
        //Audio
        newInfoObj.showButton = showButton;
        
        //For Image 
        newInfoObj.ratioMode = ratioMode;
        newInfoObj.useOriginalSize = useOriginalSize;  
        
        //For Target Id
        newInfoObj.target_page_id = target_page_id;
        
        //For Scroll Width/Height
        newInfoObj.scroll_width = scroll_width;
        newInfoObj.scroll_height = scroll_height; 
        
        //For Video Player Controller
        newInfoObj.style = style;
        
        newInfoObj.fade = fade;
        
        //Copy Data For Start Animation
        newInfoObj.startOffX = startOffX ;
        newInfoObj.startOffY =  startOffY ;
        newInfoObj.startAlpha = startAlpha ;   
        newInfoObj.delay = delay ;
        newInfoObj.duration = duration;
        newInfoObj.transitionType = transitionType ;
        
        //animation
        newInfoObj.ani = ani;
        newInfoObj.anistartindex = anistartindex;
        newInfoObj.aniendindex = aniendindex;
        newInfoObj.anirepeat = anirepeat;
        newInfoObj.aniduration = aniduration;
        newInfoObj.discrete = discrete;
        //NSLog(@"copy ani data->%d",newInfoObj.ani);
    }
}

-(void) toString
{
    NSLog(@"type:%@ res:%@ x:%f y:%f width:%f height%f \n",type,resPath,x,y,width,height);
}

-(void) reset
{
    if(imgArr)
    {
        [imgArr removeAllObjects];
        [imgArr release];
    }
    
    if(type)
    {
        [type release];
    }
    
    if(resPath)
    {
        [resPath release];
    }
    
}

@end
